package com.atguigu.yygh.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/*==========================================
      时 间:   2022-04-12
      讲 师:   刘  辉
      描 述:   尚硅谷教学团队
 ==========================================*/
@Configuration
@EnableSwagger2 //开启Swagger支持
public class SwaggerConfig {


    //
    @Bean
    public Docket adminDocket(){
        return new Docket(DocumentationType.SWAGGER_2).groupName("admin").apiInfo(adminApiInfo()).select().paths(PathSelectors.regex("/admin/.*")).build();
    }
    @Bean
    public Docket userDocket(){
        return new Docket(DocumentationType.SWAGGER_2).groupName("user").apiInfo(userApiInfo()).select().paths(PathSelectors.regex("/user/.*")).build();
    }
    @Bean
    public Docket apiDocket(){
        return new Docket(DocumentationType.SWAGGER_2).groupName("api").apiInfo(apiInfo()).select().paths(PathSelectors.regex("/api/.*")).build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("Api文档")
                .description("医院系统各个接口文档...")
                .version("v1.0")
                .contact(new Contact("佟老师","http://www.atguigu.com","atguigu@163com"))
                .build();
    }


    private ApiInfo adminApiInfo(){
        return new ApiInfoBuilder().title("管理员系统Api文档").build();
    }

    private ApiInfo userApiInfo(){
        return new ApiInfoBuilder()
                .title("用户系统Api文档")
                .description("用户系统各个接口文档...")
                .version("v1.0")
                .contact(new Contact("佟老师","http://www.atguigu.com","atguigu@163com"))
                .build();
    }
}
